home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 February / EnigmA AMIGA RUN 15 (1997)(G.R. Edizioni)(IT)[!][issue 1997-02][PLANET CD V].iso / enigma / earcd / varie / rpn_calc.lha / rpn_calc / RPN_Calc.bas < prev    next >
BASIC Source File  |  1994-03-22  |  15KB  |  1,026 lines

  1. REM $option y+,k25            'window defeat, no icon ,larger heap
  2. REM $option b-                'break check off
  3. ON ERROR GOTO errhandler
  4. ON BREAK GOSUB brkhandler
  5. CALL menuinit
  6. ON MENU GOSUB menuhandler
  7. MENU ON
  8. BREAK ON
  9. RANDOMIZE TIMER
  10.  
  11. 't[1-9] = temporary float vars
  12. 's[1-9] = temporary int vars
  13. 't[1-9]$ = temp. strings
  14. 'i,j =loop variables
  15. 'pl,pp () = play vars
  16. 'rc,rcount () =repeat vars
  17. 'rptcnt,plng =rpt/play nesting
  18. 'cond,eos,play,rpt,none,norm,chk = boolean
  19. 'sp = string pos.
  20. 'i$,a$ = input strings
  21. 'a,b =calc vars
  22.  
  23. DEFINT i,j,p,r,f
  24. DEFINT c,e,s,n,o
  25. DEFDBL g,h,v,t,a,b
  26.  
  27. CONST plydepth=20
  28. CONST rptdepth=20
  29. CONST reclevels=40
  30. CONST stacksize=100
  31. CONST strue=-1
  32. CONST false=0
  33.  
  34. DIM SHARED vars(25)
  35. DIM SHARED rec$(25,reclevels)
  36. DIM SHARED heap(stacksize)
  37. DIM SHARED pl(plydepth),pp(plydepth)
  38. DIM SHARED rc(rptdepth),rcount(rptdepth)
  39. DIM SHARED q$(rptdepth)
  40. DIM SHARED silent,offset,cond
  41. DIM SHARED eos,sp,play,rpt
  42. DIM SHARED plng,rptcnt
  43. DIM SHARED cond,a$,sep$,i$,sp
  44. DIM SHARED ws$
  45. pi#=3.14159265358979324
  46. e#=2.71828182845904524
  47. trig=1
  48. DECLARE FUNCTION gettop()
  49. DECLARE FUNCTION getstack()
  50. DECLARE FUNCTION getword$()
  51. DECLARE FUNCTION chknum()
  52. DECLARE FUNCTION getnum()
  53. DECLARE FUNCTION getletter()
  54. WINDOW 1,"RPN_Calc",,31
  55. FOR i=0 TO 25
  56.     rec$(i,1)="q"
  57.     vars(i)=0
  58. NEXT
  59. ws$=" "+CHR$(9)+","
  60. offset=0
  61. cond=false
  62. play=false
  63. rpt=false
  64. a$=""
  65. sep$=" Result: "
  66. WHILE strue
  67. getln:
  68. PRINT offset+1;
  69. INPUT ": ",i$
  70. IF i$="" THEN
  71.     GOTO getln:
  72. END IF
  73. com:
  74. eos=false:sp=1
  75. WHILE NOT eos
  76. a$=getword$()
  77. a$=LCASE$(a$)
  78.  
  79. SELECT CASE a$
  80.  
  81. CASE "help","info"
  82.     GOSUB help:
  83.     
  84.  
  85. CASE "getval","getvalue" 
  86.     s=gettop()
  87.     IF s<=offset THEN
  88.         t=getstack(s)
  89.         strout sep$
  90.         numout t
  91.         newline
  92.     ELSE
  93.         strout sep$+"NULL"
  94.         newline
  95.     END IF
  96.  
  97.  
  98. CASE "swap"
  99.     t1=gettop()
  100.     t2=gettop()
  101.     putstack t1
  102.     putstack t2
  103.  
  104.  
  105. CASE "gettop"
  106.     t=gettop()
  107.     putstack t
  108.     strout sep$
  109.     numout t
  110.     newline
  111.  
  112.  
  113. CASE "dupl","duplicate"
  114.     t=gettop()
  115.     putstack t
  116.     putstack t
  117.  
  118.  
  119. CASE "?","lookstack"  
  120.     s=getnum()-1
  121.     IF s<offset AND s=>0 THEN
  122.         t=getstack(s)
  123.         strout sep$
  124.         numout t
  125.         newline
  126.     ELSE
  127.         strout sep$+"NULL"
  128.         newline
  129.     END IF
  130.  
  131.  
  132. CASE "curpos"
  133.     s=offset
  134.     putstack s
  135.     strout sep$
  136.     numout s
  137.     newline
  138.  
  139.  
  140. CASE "back"
  141.     IF offset>0 THEN offset=offset-1
  142.  
  143.  
  144. CASE "%","setoffset" 
  145.     s=getnum()-1
  146.     IF s<=offset AND s>=0 THEN offset=s
  147.  
  148.  
  149. CASE "#","getstack" 
  150.     s=getnum()-1
  151.     IF s<=offset AND s>0 THEN
  152.         t=getstack(s)
  153.         strout sep$
  154.         numout t
  155.         newline
  156.         putstack t
  157.     ELSE 
  158.         PRINT sep$;"NULL"
  159.     END IF
  160.  
  161.  
  162. CASE "plot"
  163.     t2=gettop()
  164.     t1=gettop()
  165.     PSET(WINDOW(2)/2+t1,WINDOW(3)/2-t2)
  166.  
  167.  
  168. CASE "winwi","windowwidth" 
  169.     putstack WINDOW(2)/2
  170.  
  171.  
  172. CASE "winhi","windowheigth"
  173.     putstack WINDOW(3)/2
  174.  
  175.  
  176. CASE "locate","setcursorpos"
  177.     t1=gettop()
  178.     t2=gettop()
  179.     LOCATE t2,t1
  180.  
  181.  
  182. CASE "getnum","inputnum"
  183.     INPUT "",t
  184.     putstack t
  185.  
  186.  
  187. CASE "$","getvar"
  188.     s=getletter()
  189.     IF s<0 THEN 
  190.         PRINT "Bad args"
  191.     ELSE
  192.         putstack vars(s)
  193.         strout sep$
  194.         numout vars(s)
  195.         newline
  196.     END IF
  197.  
  198.  
  199. CASE "set","setvar"
  200.     s=getletter()
  201.     IF s<0 THEN
  202.         PRINT "Bad args"
  203.     ELSE
  204.         t=gettop()
  205.         vars(s)=t
  206.         putstack t
  207.     END IF
  208.  
  209.  
  210. CASE "get","lookvar" 
  211.     s=getletter()
  212.     IF s<0 THEN
  213.         PRINT "Bad args"
  214.     ELSE
  215.         t=gettop()
  216.         vars(s)=t
  217.     END IF
  218.  
  219.  
  220. CASE "saveall" 
  221.     INPUT "Filename : ",f$
  222.     OPEN f$ FOR OUTPUT AS 1
  223.     FOR i=0 TO 25
  224.         FOR g=j TO reclevels
  225.             t$=rec$(i,j)
  226.             PRINT #1,t$
  227.             IF t$="q" THEN
  228.                 EXIT FOR
  229.             END IF
  230.         NEXT
  231.     NEXT
  232.     CLOSE 1
  233.  
  234.  
  235. CASE "loadall"
  236.     INPUT "Filename : ",f$
  237.     IF NOT FEXISTS(f$) THEN
  238.         PRINT "Can't find ";f$
  239.     ELSE
  240.         OPEN f$ FOR INPUT AS 1
  241.         FOR i=0 TO 25
  242.             FOR j=1 TO reclevels
  243.                 INPUT #1,t$
  244.                 rec$(i,j)=t$
  245.                 IF temp$="q" THEN
  246.                     EXIT FOR
  247.                 END IF
  248.             NEXT
  249.         NEXT
  250.         CLOSE 1
  251.     END IF
  252.  
  253.  
  254. CASE "save"
  255.     s=getletter()
  256.     IF s<0 THEN
  257.         PRINT "Bad args"
  258.     ELSE
  259.         INPUT "Filename : ",f$
  260.         OPEN f$ FOR OUTPUT AS 1
  261.         FOR i=1 TO reclevels
  262.             t$=rec$(s,i)
  263.             PRINT #1,t$
  264.             IF t$="q" THEN
  265.                 EXIT FOR
  266.             END IF
  267.         NEXT
  268.         CLOSE 1
  269.     END IF
  270.  
  271.  
  272. CASE "load" 
  273.     s=getletter()
  274.     IF s<0 THEN
  275.         PRINT "Bad args"
  276.     ELSE
  277.         INPUT "Filename : ",f$
  278.         IF NOT FEXISTS(f$) THEN
  279.             PRINT "Can't find ";f$
  280.         ELSE
  281.             OPEN f$ FOR INPUT AS 1
  282.             FOR i=1 TO reclevels
  283.                 INPUT #1,t$
  284.                 rec$(s,i)=t$
  285.                 IF t$="q" THEN
  286.                     EXIT FOR
  287.                 END IF
  288.             NEXT
  289.             CLOSE 1
  290.         END IF
  291.     END IF
  292.  
  293.  
  294. CASE "'","print" 
  295.     PRINT getword$    
  296.  
  297.  
  298. CASE "rep","repeat"        'should be a recursive SUB-prog. instead
  299.     INCR rptcnt
  300.     rcount(rptcnt)=getnum()
  301.     IF NOT play THEN
  302.         INPUT "Command : ",q$(rptcnt)
  303.     ELSE 
  304.         INCR pl(plng)
  305.         q$(rptcnt)=rec$(pp(plng),pl(plng))
  306.     END IF
  307.     rpt=strue
  308.     rc(rptcnt)=1
  309.     WHILE rc(rptcnt)<=rcount(rptcnt)        'no arrays in FOR..NEXT loops
  310.         i$=q$(rptcnt)
  311.         GOSUB com
  312.         INCR rc(rptcnt)
  313.     WEND
  314.     DECR rptcnt
  315.     IF rptcnt=0
  316.         rpt=false
  317.     END IF
  318.  
  319. CASE "clr","clearall","reset"
  320.     trig=1
  321.     cond=false
  322.     play=false
  323.     rpt=false
  324.     silent=false
  325.     offset=0
  326.     rptcnt=0
  327.     plng=0
  328.     FOR i=0 TO 25
  329.         vars(i)=0
  330.         rec$(i,1)="q"
  331.     NEXT
  332.     CLS
  333.  
  334.  
  335. CASE "cls","clearscreen"
  336.     CLS
  337.  
  338.  
  339. CASE "rec","record"
  340.     s=getletter()
  341.     IF s<0 THEN
  342.         PRINT "Bad args"
  343.     ELSE
  344.         FOR i=1 TO reclevels
  345.             INPUT "Record: ",rec$(s,i)
  346.             IF rec$(s,i)="q" OR rec$(s,i)="quit" THEN EXIT FOR
  347.         NEXT
  348.     END IF
  349.  
  350.  
  351. CASE "play"
  352.     INCR plng
  353.     pp(plng)=getletter()
  354.     IF pp(plng)<0 THEN
  355.         PRINT "Bad args"
  356.     ELSE
  357.         play=strue
  358.         pl(plng)=1
  359.         WHILE pl(plng)<=reclevels
  360.             i$=rec$(pp(plng),pl(plng))
  361.             IF i$="q" OR i$="quit" THEN 
  362.                 i$=""
  363.                 EXIT WHILE
  364.             END IF
  365.             GOSUB com
  366.             INCR pl(plng)
  367.         WEND
  368.     END IF
  369.     DECR plng
  370.     IF plng=0 THEN
  371.         play=false
  372.     END IF
  373.  
  374.  
  375. CASE "texton" 
  376.     silent=false
  377.  
  378.  
  379. CASE "textoff" 
  380.     silent=strue
  381.  
  382.  
  383. CASE "goto"
  384.     s=getnum()
  385.     IF play THEN
  386.         pl(plng)=s-1
  387.     END IF
  388.  
  389.  
  390. CASE "gotop"
  391.     s=gettop()
  392.     IF play THEN
  393.         pl(plng)=s-1
  394.     END IF
  395.  
  396.  
  397. CASE "gocon"
  398.     s=getnum()
  399.     IF play AND cond THEN
  400.         pl(plng)=s-1
  401.         cond=false
  402.     END IF
  403.  
  404.  
  405. CASE "gotopcon"
  406.     s=gettop()
  407.     IF play AND cond THEN
  408.         pl(plng)=s-1
  409.         cond=false
  410.     END IF
  411.  
  412.  
  413. CASE "rvscon","change_condition"
  414.     IF cond THEN
  415.         cond=false
  416.     ELSE    
  417.         cond=strue
  418.     END IF
  419.  
  420.  
  421. CASE "checkcon"
  422.     printcon
  423.     
  424.  
  425. CASE "deg","degrees"
  426.     trig=pi#/180
  427.     
  428.  
  429. CASE "rad","radians"
  430.     trig=1
  431.     
  432.  
  433. CASE "gra","gradians"
  434.     trig=pi#/200
  435.     
  436.  
  437. CASE "pi"
  438.     putstack pi#
  439.     
  440. CASE "e"
  441.     putstack e#
  442.     
  443.     
  444. CASE "rnd","random"
  445.     t=RND
  446.     putstack t
  447.     printres t
  448.     
  449.  
  450. CASE "q","quit"
  451.     WINDOW CLOSE 1
  452.     SYSTEM
  453.  
  454.  
  455. CASE ELSE 
  456.     GOSUB calc
  457.  
  458.  
  459. END SELECT
  460.  
  461.  
  462. WEND
  463. IF play THEN RETURN
  464. IF rpt THEN RETURN
  465. WEND
  466.     
  467.  
  468.  
  469.  
  470. calc:
  471. norm=strue
  472. chk=false
  473. none=false
  474. SELECT CASE offset
  475. CASE 0
  476.     a=0
  477.     b=0
  478.     none=strue
  479.     norm=false
  480. CASE 1
  481.     a=gettop()
  482.     b=0
  483.     norm=false
  484. CASE ELSE
  485.     a=gettop()
  486.     b=gettop()
  487. END SELECT
  488.  
  489. SELECT CASE a$
  490.  
  491. CASE "not","~" 
  492.     a=NOT a
  493.  
  494. CASE "neg" 
  495.     a=-a
  496.  
  497. CASE "exp"
  498.     a=EXP(a)
  499.  
  500. CASE "ln" 
  501.     a=LOG(a)
  502.     
  503. CASE "lg"  
  504.     a=LOG10(a)
  505.     
  506. CASE "sin" 
  507.     a=SIN(a*trig)
  508.     
  509. CASE "cos"  
  510.     a=COS(a*trig)
  511.     
  512. CASE "tan" 
  513.     a=TAN(a*trig)
  514.  
  515. CASE "cot","cotan"
  516.     a=1/TAN(a*trig)
  517.         
  518. CASE "atn","arctan" 
  519.     a=ATN(a)/trig
  520.  
  521. CASE "acot","arccot"
  522.     a=(1/ATN(a))/trig
  523.         
  524. CASE "asin","arcsin"
  525.     a=ATN(a/SQR(-a*a+1))/trig
  526.     
  527. CASE "acos","arccos"
  528.     a=(-ATN(a/SQR(-a*a+1))+pi/2)/trig
  529.     
  530. CASE "sinh"
  531.     a=((EXP(a)-EXP(-a))/2)/trig
  532.     
  533. CASE "cosh"
  534.     a=((EXP(a)+EXP(-a))/2)/trig
  535.     
  536. CASE "tanh"
  537.     a=((EXP(-a)/EXP(a)+EXP(-a))*2+1)/trig
  538.     
  539. CASE "coth"
  540.     a=(EXP(-a)/(EXP(a)-EXP(-a))*2+1)/trig
  541.  
  542.  
  543.  
  544.     
  545.     
  546. CASE "abs" 
  547.     a=ABS(a)
  548.     
  549. CASE "sqrt","root","squareroot" 
  550.     a=SQR(a)
  551.     
  552. CASE "sqr","square" 
  553.     a=a*a
  554.     
  555. CASE "cube"
  556.     a=a*a*a
  557.     
  558. CASE "int"  
  559.     a=INT(a+0.5)
  560.     
  561. CASE "trunc" 
  562.     a=INT(a)
  563.  
  564. CASE "frac" 
  565.     a=a-INT(a)
  566.     
  567. CASE "fac","faculty"
  568.     t=1
  569.     FOR i=1 TO a
  570.         t=t*g
  571.     NEXT
  572.     a=t
  573.  
  574. CASE "+","plus" 
  575.     a=a+b
  576.     norm=false
  577.     
  578. CASE "-","minus" 
  579.     a=a-b
  580.     norm=false
  581.     
  582. CASE "*" 
  583.     a=a*b
  584.     norm=false
  585.     
  586. CASE "/" 
  587.     a=a/b
  588.     norm=false
  589.     
  590. CASE "^","pow","power"
  591.     a=a^b
  592.     norm=false
  593.     
  594. CASE "<<","leftshift","shiftleft" 
  595.     a=a*2^b
  596.     norm=false
  597.     
  598. CASE ">>","rightshift","shiftright"
  599.     a=a*.5^b
  600.     norm=false
  601.     
  602. CASE "mod","modulus"
  603.     a=a MOD b
  604.     norm=false
  605.     
  606. CASE "|","!","or" 
  607.     a=a OR b
  608.     norm=false
  609.     
  610. CASE "&","and" 
  611.     a=a AND b
  612.     norm=false
  613.     
  614. CASE "xor"
  615.     a=a XOR b
  616.     norm=false
  617.  
  618. CASE "<","less_than"
  619.     IF a<b THEN cond=strue ELSE cond=false
  620.     chk=strue
  621.     printcon
  622.  
  623. CASE ">","greater_than"
  624.     IF a>b THEN cond=strue ELSE cond=false
  625.     chk=strue
  626.     printcon
  627.     
  628. CASE "=","equal"
  629.     IF a=b THEN cond=strue ELSE cond=false
  630.     chk=strue
  631.     printcon
  632.     
  633. CASE "<=","=<","less_or_equal"
  634.     IF a<=b THEN cond=strue ELSE cond=false
  635.     chk=strue
  636.     printcon
  637.     
  638. CASE ">=","=>","greater_or_equal"
  639.     IF a>=b THEN cond=strue ELSE cond=false
  640.     chk=strue
  641.     printcon
  642.     
  643. CASE "<>","notequal"
  644.     IF a<>b THEN cond=strue ELSE cond=false
  645.     chk=strue
  646.     printcon
  647.  
  648. CASE ELSE
  649.     IF norm THEN
  650.         putstack b
  651.         putstack a
  652.     ELSEIF NOT none THEN
  653.         putstack a
  654.     END IF
  655.     IF chknum(a$) THEN
  656.         putstack VAL(a$)
  657.     ELSE
  658.         PRINT "Syntax error"
  659.     END IF
  660.     RETURN
  661.     
  662. END SELECT
  663.  
  664.  
  665. IF norm THEN 
  666.     putstack b
  667. END IF
  668. putstack a
  669. IF NOT chk THEN 
  670.     printres a
  671. END IF
  672.  
  673.  
  674. RETURN
  675.  
  676.  
  677.  
  678. SUB menuinit
  679. MENU 1,0,1,"Project"
  680.     MENU 1,1,1,"Quit"
  681.  
  682.  
  683.  
  684. END SUB
  685.  
  686.  
  687. SUB printres (VAL t)
  688. strout sep$
  689. numout t
  690. newline
  691. END SUB
  692.  
  693.  
  694. SUB printcon
  695. IF NOT cond THEN 
  696.     strout sep$+"FALSE"
  697.     newline
  698. ELSE 
  699.     strout sep$+"strue"
  700.     newline
  701. END IF
  702. END SUB
  703.  
  704.  
  705. SUB strout (t$)
  706. IF NOT silent THEN
  707.     PRINT t$;
  708. END IF
  709. END SUB
  710.  
  711.  
  712. SUB numout (VAL t)
  713. IF NOT silent THEN
  714.     PRINT t;
  715. END IF
  716. END SUB
  717.  
  718.  
  719. SUB newline
  720. IF NOT silent THEN
  721.     PRINT
  722. END IF
  723. END SUB
  724.  
  725.  
  726. SUB putstack (VAL t)
  727. IF offset=stacksize THEN 
  728.     EXIT SUB
  729. END IF
  730. heap(offset)=t
  731. INCR offset
  732. END SUB
  733.  
  734.  
  735. FUNCTION gettop()
  736. IF offset=0 THEN 
  737.     gettop=0
  738.     EXIT FUNCTION
  739. END IF
  740. DECR offset
  741. gettop=heap(offset)
  742. END FUNCTION
  743.  
  744.  
  745. FUNCTION getstack(VAL t)
  746. IF t<0 OR t>=offset THEN 
  747.     getstack=0
  748.     EXIT FUNCTION
  749. END IF
  750. getstack=heap(t)
  751. END FUNCTION
  752.  
  753.  
  754. FUNCTION getword$()
  755. STATIC l,eow,sow,t1$,t2$
  756. eow=false:sow=false
  757. l=LEN(i$)
  758. t1$=""
  759. WHILE sp<l+1 AND NOT sow
  760.     t2$=MID$(i$,sp,1)
  761.     IF INSTR(ws$,t2$)<>0 THEN
  762.         INCR sp
  763.     ELSE
  764.         sow=strue
  765.     END IF
  766. WEND
  767. WHILE sp<l+1 AND NOT eow
  768.     t2$=MID$(i$,sp,1)
  769.     IF INSTR(ws$,t2$)<>0 THEN
  770.         eow=strue
  771.     ELSE
  772.         t1$=t1$+t2$
  773.     END IF
  774.     INCR sp
  775. WEND
  776. IF sp=l+1 THEN eos=strue
  777. getword$=t1$
  778. END FUNCTION
  779.  
  780. FUNCTION chknum (t1$)
  781. STATIC i,t2$
  782. chknum=strue
  783. FOR i=1 TO LEN(t1$)
  784.     t2$=MID$(t1$,i,1)
  785.     SELECT CASE t2$
  786.     CASE "e","d"
  787.         IF i=1 THEN
  788.             chknum=false
  789.             EXIT FUNCTION
  790.         ELSE
  791.             EXIT SELECT
  792.         END IF
  793.     CASE ".","+","-"
  794.         EXIT SELECT
  795.     CASE <"0",>"9"
  796.         chknum=false
  797.         EXIT FUNCTION
  798.     END SELECT
  799. NEXT
  800. END FUNCTION
  801.  
  802. FUNCTION getnum()
  803. STATIC t$
  804. t$=getword$()
  805. IF chknum(t$) THEN
  806.     getnum=VAL(t$)
  807. ELSE
  808.     ERROR 5
  809. END IF
  810. END FUNCTION
  811.  
  812. FUNCTION getletter()
  813. STATIC t,t$
  814. t$=getword$()
  815. t=ASC(LEFT$(t$,1))-ASC("a")
  816. IF LEN(t$)<>1 OR t<0 OR t>25 THEN
  817.     getletter=-1
  818. ELSE
  819.     getletter=t
  820. END IF
  821. END FUNCTION
  822.  
  823.  
  824. errhandler:
  825. ern=ERR
  826. IF ern=11 THEN
  827.     PRINT "Division by zero"
  828.     i$="0"
  829.     ON ERROR GOTO errhandler
  830.     RESUME getln:
  831. ELSEIF ern=6 THEN
  832.     PRINT "Overflow"
  833.     a$="1.79769313486e308"
  834.     ON ERROR GOTO errhandler
  835.     RESUME com:
  836. ELSEIF ern=5 THEN
  837.     PRINT "Illegal args"
  838.     i$="0"
  839.     ON ERROR GOTO errhandler
  840.     RESUME getln:
  841. ELSE
  842.     ON ERROR GOTO 0
  843. END IF
  844.  
  845.  
  846. brkhandler:
  847. rc(plng)=rcount(plng)+1
  848. pl(plng)=reclevels+1
  849. RETURN
  850.  
  851.  
  852. menuhandler:
  853. menunum=MENU(0)
  854. menuitem=MENU(1)
  855. SELECT CASE menunum
  856.  
  857. CASE 0
  858.     RETURN
  859.  
  860. CASE 1
  861.     SELECT CASE menuitem
  862.     
  863.     CASE 1
  864.         SYSTEM
  865.         
  866.     END SELECT
  867.  
  868. END SELECT
  869.  
  870.  
  871. RETURN
  872.  
  873.  
  874.  
  875.  
  876.  
  877. help:
  878. t$=LCASE$(getword$())
  879. SELECT CASE t$
  880.  
  881. CASE "help","info"
  882.     PRINT "[help ,info]"
  883.     PRINT "This command gives you info about the specified"
  884.     PRINT "command/operation."
  885.     
  886. CASE "getval","getvalue"
  887.     PRINT "[getval ,getvalue]"
  888.     PRINT "This command prints out the contents of the cell whose"
  889.     PRINT "number is specified by the contents of the top cell."
  890.     
  891. CASE "swap"
  892.     PRINT "[swap]"
  893.     PRINT "This command swaps the contents of the two top cells."
  894.     
  895. CASE "gettop"
  896.     PRINT "[gettop]"
  897.     PRINT "This command prints the contents of the top cell."
  898.     
  899. CASE "dupl","duplicate"
  900.     PRINT "[dupl ,duplicate]"
  901.     PRINT "This command puts a new copy of the contents of the top cell"
  902.     PRINT "onto the stack."
  903.  
  904. CASE "?","lookstack"
  905.     PRINT "[? ,lookstack]"
  906.     PRINT "This command prints out the contents of the specified cell."
  907.     
  908. CASE "currentpos"
  909.     PRINT "[currentpos]"
  910.     PRINT "This command puts the current stack position on the top of"
  911.     PRINT "the stack."
  912.     
  913. CASE "back"
  914.     PRINT "[back]"
  915.     PRINT "This command decrements the stack position by 1, thus erasing"
  916.     PRINT "the contents of the top cell."
  917.     
  918. CASE "%","setoffset"
  919.     PRINT "[% ,setoffset]"
  920.     PRINT "This command sets the stack position to the specified number"
  921.     PRINT "if it is less than the current position."
  922.     
  923. CASE "#","getstack"
  924.     PRINT "[# ,getstack]"
  925.     PRINT "This command puts the contents of the specified cell on top"
  926.     PRINT "of the stack."
  927.  
  928. CASE "plot"
  929.     PRINT "[plot]"
  930.     PRINT "This command sets a pixel. The x-coordinate is taken from the"
  931.     PRINT "top of the stack and the y-coordinate from the next cell."
  932.     
  933. CASE "winwi","windowwidth"
  934.     PRINT "[winwi ,windowwidth]"
  935.     PRINT "This command puts the width (in pixels) of the output window"
  936.     PRINT "on the top of the stack."
  937.     
  938. CASE "winhi","windowheight"
  939.     PRINT "[winhi ,windowheight]"
  940.     PRINT "This command puts the height (in pixels) of the output window"
  941.     PRINT "on the top of the stack."
  942.  
  943. CASE "locate","setcursorpos"
  944.     PRINT "[locate ,setcursorpos]"
  945.     PRINT "This command move the cursor to the x-y coordinate specified"
  946.     PRINT "by the two top stack positions respectively."
  947.     
  948. CASE "getnum","inputnum"
  949.     PRINT "[getnum ,inputnum]"
  950.     PRINT "This command reads a number from the keyboard and puts it"
  951.     PRINT "on the top of the stack."
  952.     
  953. CASE "$","getvar"
  954.     PRINT "[$ ,getvar]"
  955.     PRINT "This function takes the value of the specified variable and"
  956.     PRINT "puts it on the stack."
  957.     
  958. CASE "set","setvar"
  959.     PRINT "[set ,setvar]"
  960.     PRINT "This command sets the specified variable to the value located"
  961.     PRINT "at the top of the stack witout disrupting the stack."
  962.     
  963. CASE "get","lookvar"
  964.     PRINT "[get ,lookvar]"
  965.     PRINT "This command pulls a number from the top of the stack and"
  966.     PRINT "assigns it to the specified variable."
  967.     
  968. CASE "saveall"
  969.     PRINT "[saveall]"
  970.     PRINT "Prompts for a filename and saves all programs to that file."
  971.     
  972. CASE "loadall"
  973.     PRINT "[loadall]"
  974.     PRINT "Prompts for a filename and loads all programs from that file."
  975.     PRINT "Each program is terminated by a 'q'."
  976.     
  977. CASE "save"
  978.     PRINT "[save]"
  979.     PRINT "Prompts for filename and saves the specified program (a-z)"
  980.     PRINT "to that file."
  981.     
  982. CASE "load"
  983.     PRINT "[load]"
  984.     PRINT "Asks for a filename and loads the specified program from"
  985.     PRINT "that file."
  986.     
  987. CASE "'","print"
  988.     PRINT "[' ,print]"
  989.     PRINT "Puts the supplied word on the screen."
  990.     
  991. CASE "rep","repeat"
  992.     PRINT "[rep ,repeat]"
  993.     PRINT "Repeats a command for the supplied number of times."
  994.     
  995. CASE "clr","clearall","reset"
  996.     PRINT "[clr ,clearall ,reset]"
  997.     PRINT "Clears all programs ,sets all variables to zero and resets"
  998.     PRINT "everything else to the state it was at from the start."
  999.     
  1000. CASE "cls","clearscreen"
  1001.     PRINT "[cls ,clearscreen]"
  1002.     PRINT "Clears the screen."
  1003.     
  1004.     
  1005.     
  1006.     
  1007.     
  1008.  
  1009.  
  1010.     
  1011.     
  1012.     
  1013.     
  1014.  
  1015.  
  1016.  
  1017.  
  1018. CASE ELSE
  1019.     PRINT "Unknown command/function."
  1020.     
  1021. END SELECT
  1022. RETURN
  1023.  
  1024.  
  1025.  
  1026.